<template>
  <div id="abnormaldetail">
    <div class="homeTitle">异常业务预警详情</div>
    <table>
      <tr>
        <td>预警行社\机构</td>
        <td>{{data.bankName}}</td>
      </tr>
      <tr>
        <td>预警日期</td>
        <td>{{data.spotDate}}</td>
      </tr>
      <tr>
        <td>描述</td>
        <td>{{data.descData}}</td>
      </tr>
    </table>
    <!-- 标签 -->
    <div class="tag">
      <span v-if="data.mainTypeOne">{{data.mainTypeOne}}</span>
      <span v-if="data.mainTypeTwo">{{data.mainTypeTwo}}</span>
    </div>
    <div class="btn">
      <el-button size="mini" v-if="data.isFocus == 0" @click="setFocus(data,1)" type="primary">关注</el-button>
      <el-button size="mini" v-else @click="setFocus(data,0)" type="primary">取消关注</el-button>
      <el-button type="primary" size="small" @click="close">关闭</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'abnormaldetail',
  data () {
    return {
      data: ''
    };
  },
  mounted () {
    this.getdata();
  },
  methods: {
    getdata () {
      this.axios.get('unusualWarn/showWarn',{params: {warnId: this.$route.query.id}})
        .then(({data})=> {
          this.data = data.data;
        })
    },
    setFocus (row,val) {
      this.axios.post('unusualWarn/setFocus',{warnId: this.$route.query.id-0, state: val})
        .then(({data})=> {
          if(val==1) row.isFocus = 1;
          if(val==0) row.isFocus = 0;
          this.$message({message: '设置成功',type: 'success'});
        })
    },
    close () {
      this.$router.go(-1);
    }
  }
};
</script>

<style lang="scss">
  #abnormaldetail {
    table {
      margin-top: 30px;
      color: white;
      font-size: 14px;
      border: 1px solid white;
      width: 100%;
      border-collapse: collapse;
      tr {
        td {
         text-align: center;
         padding: 12px;
         border-right: 1px solid white;
         border-bottom: 1px solid white;
         &:first-child {
           background-color: rgba(0, 0, 0, .7)
         }
         &:last-child {
           background-color: rgba(0, 0, 0, .3)
         }
        }
      }
    }
    .tag {
      margin-top: 20px;
      >span {
        padding: 5px 10px;
        border: 1px solid black;
        background-color: #FF8080;
        font-size: 14px;
        margin-right: 20px;
      }
    }
    .btn {
      margin-top: 20px;
      display: flex;
      justify-content: center;
      .el-button {
        margin-right: 20px;
      }
    }
  }
</style>
